package com.code2roc.fastboot.framework.extra.errorhandle;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class ResponseStatusInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(response.getStatus()==404){
            response.sendRedirect(request.getContextPath() + "/frame/error/404");
            return false;
        }
        return true;
    }

}
